home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / VideoFolder 1.0a / Source / VideoFolderApp.cp < prev    next >
Text File  |  1996-06-22  |  5KB  |  179 lines

  1. // ===========================================================================
  2. //    <PP Starter Source>.cp         ©1994-1996 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    This file contains the starter code for a PowerPlant application
  6.  
  7. #include "VideoFolderApp.h"
  8.  
  9. #include <LGrowZone.h>
  10. #include <LWindow.h>
  11. #include <PP_Messages.h>
  12. #include <PP_Resources.h>
  13. #include <PPobClasses.h>
  14. #include <UDrawingState.h>
  15. #include <UMemoryMgr.h>
  16. #include <URegistrar.h>
  17. #include <LEditField.h>
  18.  
  19. #include "DateTimeDisplayPane.h"
  20. #include "FSSpecPane.h"
  21. #include "SequenceGrabberPane.h"
  22. #include "VideoFolderDocument.h"
  23. #include "VideoFolderWindow.h"
  24. #include <UModalDialogs.h>
  25.  
  26. // put declarations for resource ids (ResIDTs) here
  27.  
  28.  
  29. // ===========================================================================
  30. //        • Main Program
  31. // ===========================================================================
  32.  
  33. void main(void)
  34. {
  35.                                     // Set Debugging options
  36.     #if debug
  37.     SetDebugThrow_(debugAction_SourceDebugger );
  38.     SetDebugSignal_(debugAction_SourceDebugger );
  39.     #else                            
  40.     SetDebugThrow_(debugAction_Nothing );
  41.     SetDebugSignal_(debugAction_Nothing );
  42.     #endif
  43.  
  44.     InitializeHeap(3);                // Initialize Memory Manager
  45.                                     // Parameter is number of Master Pointer
  46.                                     //   blocks to allocate
  47.     
  48.                                     // Initialize standard Toolbox managers
  49.     UQDGlobals::InitializeToolbox(&qd);
  50.     
  51.     new LGrowZone(20000);            // Install a GrowZone function to catch
  52.                                     //    low memory situations.
  53.  
  54.     VideoFolderApp    theApp;            // replace this with your App type
  55.     theApp.Run();
  56. }
  57.  
  58.  
  59. // ---------------------------------------------------------------------------
  60. //        • VideoFolderApp             // replace this with your App type
  61. // ---------------------------------------------------------------------------
  62. //    Constructor
  63.  
  64. VideoFolderApp::VideoFolderApp()
  65. {
  66.     // Register functions to create core PowerPlant classes
  67.     
  68.     RegisterAllPPClasses();
  69.  
  70.     URegistrar::RegisterClass(SequenceGrabberPane::class_ID,        (ClassCreatorFunc) SequenceGrabberPane::CreateSequenceGrabberPaneStream);
  71.     URegistrar::RegisterClass(VideoFolderWindow::class_ID,        (ClassCreatorFunc) VideoFolderWindow::CreateVideoFolderWindowStream);
  72.     URegistrar::RegisterClass(DateTimeDisplayPane::class_ID,        (ClassCreatorFunc) DateTimeDisplayPane::CreateDateTimeDisplayPaneStream );
  73.     URegistrar::RegisterClass(FSSpecPane::class_ID,        (ClassCreatorFunc) FSSpecPane::CreateFSSpecPaneStream );
  74.     URegistrar::RegisterClass(LCicnButton::class_ID,        (ClassCreatorFunc) LCicnButton::CreateCicnButtonStream );
  75. }
  76.  
  77.  
  78. // ---------------------------------------------------------------------------
  79. //        • ~VideoFolderApp            // replace this with your App type
  80. // ---------------------------------------------------------------------------
  81. //    Destructor
  82. //
  83.  
  84. VideoFolderApp::~VideoFolderApp()
  85. {
  86. }
  87.  
  88. // ---------------------------------------------------------------------------
  89. //        • StartUp
  90. // ---------------------------------------------------------------------------
  91. //    This function lets you do something when the application starts up
  92. //    without a document. For example, you could issue your own new command.
  93.  
  94. void
  95. VideoFolderApp::StartUp()
  96. {
  97.     ObeyCommand(cmd_New, nil);        // EXAMPLE, create a new window
  98. }
  99.  
  100. // ---------------------------------------------------------------------------
  101. //        • ObeyCommand
  102. // ---------------------------------------------------------------------------
  103. //    Respond to commands
  104.  
  105. Boolean
  106. VideoFolderApp::ObeyCommand(
  107.     CommandT    inCommand,
  108.     void        *ioParam)
  109. {
  110.     Boolean        cmdHandled = true;
  111.  
  112.     switch (inCommand) {
  113.         default:
  114.             cmdHandled = LDocApplication::ObeyCommand(inCommand, ioParam);
  115.             break;
  116.     }
  117.     
  118.     return cmdHandled;
  119. }
  120.  
  121. // ---------------------------------------------------------------------------
  122. //        • FindCommandStatus
  123. // ---------------------------------------------------------------------------
  124. //    This function enables menu commands.
  125. //
  126.  
  127. void
  128. VideoFolderApp::FindCommandStatus(
  129.     CommandT    inCommand,
  130.     Boolean        &outEnabled,
  131.     Boolean        &outUsesMark,
  132.     Char16        &outMark,
  133.     Str255        outName)
  134. {
  135.  
  136.     switch (inCommand) {
  137.     
  138.         // Return menu item status according to command messages.
  139.         // Any that you don't handle will be passed to LApplication
  140.  
  141.         default:
  142.             LDocApplication::FindCommandStatus(inCommand, outEnabled,
  143.                                                 outUsesMark, outMark, outName);
  144.             break;
  145.     }
  146. }
  147.  
  148.  
  149. LModelObject* VideoFolderApp::MakeNewDocument()
  150. {    VideoFolderDocument* doc = new VideoFolderDocument ( this, nil);
  151.  
  152.     return doc;
  153. }
  154.  
  155. void VideoFolderApp::ChooseDocument()
  156. {    StandardFileReply reply;
  157.     SFTypeList typeList = { 'VFol', 0, 0, 0 };
  158.  
  159.     UDesktop::Deactivate();
  160.     ::StandardGetFile ( nil, 1, typeList, & reply );
  161.     UDesktop::Activate();
  162.     
  163.     if ( reply.sfGood )
  164.         SendAEOpenDoc ( reply.sfFile );
  165. }
  166.  
  167. void VideoFolderApp::OpenDocument( FSSpec *inMacFSSpec)
  168. {
  169.     VideoFolderDocument* doc = new VideoFolderDocument ( this, nil );
  170. }
  171.  
  172. void VideoFolderApp::ShowAboutBox()
  173. {    StDialogHandler aboutBox ( 128, this );
  174.  
  175.     aboutBox.DoDialog(); // != msg_OK )
  176.         ;
  177. }
  178.  
  179.